Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data serialization fix #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BHandle
Copy link

@BHandle BHandle commented Jan 24, 2025

Previously, the KeepAlive pings could cause serialization errors by injecting data in-between a write header and payload. This would cause the receiving reader to receive data that was prefixed by the Ping's size header and exception.

By ensuring that only one thread has access to the writer at a time, we can eliminate this risk and ensure the integrity of Header/Payload pairs.

I also changed the second size header byte to be a modulus operation. Even over millions of iterations, modern compiled modulus is still approximately the same performance. That said, however, there was nothing wrong with the previous calculation, I just find modulus to be more clear in intent.

@BHandle
Copy link
Author

BHandle commented Jan 24, 2025

When creating this, I did not personally use the encrypted or stateful variants, and I haven't echoed any changes to those implementations. It's possible that these changes should also be performed there to keep each of them in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant